<!--<style>-->
<!--    table{-->
<!---->
<!--        table-layout:fixed;/* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */-->
<!--    }-->
<!--    td{-->
<!--        width:100%;-->
<!--        word-break:keep-all;/* 不换行 */-->
<!--        white-space:nowrap;/* 不换行 */-->
<!--        overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */-->
<!--        text-overflow:ellipsis;/* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/-->
<!--    }-->
<!--    layui-form-label{-->
<!--        width: 80px;-->
<!--    }-->
<!--</style>-->
<form class="layui-form" id="search-form">
    <div style="min-height: 38px;margin-top: 5px;">
        <div class="layui-inline" style="width: 10%;">
            <div class="layui-input-inline">
                <select name="status_type" lay-filter="online" id="status_type">
                    <option value="">审核状态</option>
                    <option value="2" >待审核</option>
                    <option value="3" >通过</option>
                    <option value="1">不通过</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">关键字</label>
            <div class="layui-input-block">
                <input type="text" name="title" placeholder="搜索呢称，关键字" autocomplete="off" class="layui-input keyword" style="width:150px;">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">日期范围</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input time" id="test6" placeholder="" style="width:200px;">
            </div>
            <button type="button" class="layui-btn layui-btn-primary search"><i class="layui-icon">&#xe615;</i> </button>
        </div>

        <button type="button" class="layui-btn no_pass" style="float: right;">批量不通过</button>
        <button type="button" class="layui-btn pass" style="float: right;">批量通过</button>
    </div>
</form>
<br>
<table class="layui-table">
    <colgroup>
        <col width="2%">
        <col width="5%">
        <col width="12%">
        <col width="30%">
        <col width="10%">
        <col width="5%">
        <col width="10%">
    </colgroup>
    <thead>
    <tr>
        <th><input type="checkbox" name="checkall" value="" title="" class="all_checkbox"></th>
<!--        <th>id</th>-->
        <th>头像</th>
        <th>用户</th>
        <th>个性签名</th>
        <th>跟新时间</th>
        <th>审核状态</th>
        <th>操作</th>
    </tr>
    </thead>

    <tbody>
    <?php if(!empty($data['row'])){
        foreach($data['row'] as $k=>$v){
            ?>
            <tr>
                <input type="hidden" value="<?=$v['user_id']?>" class="video_uuid<?=$k+1?>">
                <td><input type="checkbox" name="like[write]" value="<?=$v['user_id']?>" title=""></td>
<!--                <td>--><?//=$v['user_id']?><!--</td>-->
                <td><img src="<?=$v['nick_pic']?>" style="width:100px;height: 65px;" class="tom_show_image"></td>
                <td><?=$v['nick_name']?></td>
                <td><?=$v['user_autograph']?></td>
                <td><?=$v['update_time']?></td>
                <?php if($v['is_status']==2){ ?>
                    <td>待审核</td>
                <?php }else if($v['is_status']==1){ ?>
                    <td>不通过</td>
                <?php }else if($v['is_status']==3){ ?>
                    <td>通过</td>
                <?php } ?>
                <?php if($v['is_status']==2){ ?>
                    <td>
                        <button class="layui-btn layui-btn-xs layui-btn-danger pass<?=$k+1?>">通过</button>
                        <button class="layui-btn layui-btn-xs layui-btn-normal no_pass<?=$k+1?>">不通过</button>
                    </td>
                <?php }else if($v['is_status']==3){ ?>
                    <td>
                        <button class="layui-btn layui-btn-xs layui-btn-normal no_pass<?=$k+1?>">不通过</button>
                    </td>
                <?php }else if($v['is_status']==1){ ?>
                    <td>
                        <button class="layui-btn layui-btn-xs layui-btn-danger pass<?=$k+1?>">通过</button>
                    </td>
                <?php } ?>

            </tr>
        <?php }}else{ ?>
        <tr>
            <td colspan="7" rowspan="3" style="color: #00CC00;font-size: 25px;height:100px;text-align: center;">暂无数据</td>
        </tr>
    <?php } ?>
    </tbody>
</table>
<div id="demo7"></div>
<script src="<?=SITE_BASE_URL?>/assets/plugins/dyj/layui_url.js"></script>
<script>
    //定义一个51的jquery数组
    var arr=[];
    for(var i=1;i<51;i++){
        arr.push(i)
    }
    $.each(arr,function(i,n){
        var video_uuid=$(".video_uuid"+n).val();
        //通过
        $(".pass"+n).click(function(){
            $.ajax({
                type: "post",
                data: {video_uuid:video_uuid},
                dataType: "json",
                url: "<?=base_url("person/name/pass")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.reload()
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })
        //不通过
        $(".no_pass"+n).click(function(){
            $.ajax({
                type: "post",
                data: {video_uuid:video_uuid},
                dataType: "json",
                url: "<?=base_url("person/name/no_pass")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.reload()
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })
    })
    $(function(){
        //批量通过
        $('.pass').click(function(){
            var arr=[]
            $.each($('input:checkbox:checked'),function(i,n){
                arr.push($(this).val())
            });
            $.ajax({
                type: "post",
                data: {ids:arr},
                dataType: "json",
                url: "<?=base_url("person/name/pass_all")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.reload()
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })

        //批量通过
        $('.no_pass').click(function(){
            var arr=[]
            $.each($('input:checkbox:checked'),function(i,n){
                arr.push($(this).val())
            });
            $.ajax({
                type: "post",
                data: {ids:arr},
                dataType: "json",
                url: "<?=base_url("person/name/no_pass_all")?>",
                success: function (res) {
                    if(res.code==0){
                        layer.msg(res.msg, {time:1000},function(){
                            window.location.reload()
                        });
                    }else{
                        layer.msg(res.msg, {time: 2000});
                    }
                }
            })
        })

        //监听下拉框变化
        layui.use('form', function(){
            var form = layui.form;

            //监听话题
            form.on('select(online)', function(data){
                var join_type_sub=data.value; //得到被选中的值
                window.location.href="<?=base_url("person/name/index?online=")?>"+join_type_sub;
            });
        });

        //关键字和日期搜索
        $('.search').click(function(){
            var keyword=$('.keyword').val()
            var time=$('.time').val()
            var html="?time="+time+"&keyword="+keyword;
            var a="<?=base_url("person/name/index")?>";
            var view=a+html;
            window.location.href=view
        })
        //分页
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            var param = GetRequest();
            //总页数大于页码总数
            laypage.render({
                elem: 'demo7'
                ,count:<?=$data['total']?>//数据总数
                ,curr: <?=$page?>
                ,limit:<?=$limit?>
                ,layout:  ['count', 'prev', 'page', 'next','limit', 'refresh', 'skip']
                ,jump: function(obj,first){
                    //首次不执行
                    if(!first){
                        var url = window.location.href;
                        url = url.substring(0, url.lastIndexOf('?'));

                        param['page'] = obj.curr;
                        param['limit'] = obj.limit;
                        window.location.href = createURL(url,param);
                    }
                }
            });
        });

        //日期选择
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //日期范围
            laydate.render({
                elem: '#test6'
                ,range: '~'
            });
        })
    })
    //复选框全选与不选
    $('input[name="checkall"]').on("click",function(){
        if($(this).is(':checked')){
            $('input[name="like[write]"]').each(function(){
                $(this).prop("checked",true);
            });
        }else{
            $('input[name="like[write]"]').each(function(){
                $(this).prop("checked",false);
            });
        }
    });
</script>
